home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / encodings / zlib_codec.pyo (.txt) < prev   
Python Compiled Bytecode  |  2008-10-13  |  3KB  |  79 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import codecs
  5. import zlib
  6.  
  7. def zlib_encode(input, errors = 'strict'):
  8.     output = zlib.compress(input)
  9.     return (output, len(input))
  10.  
  11.  
  12. def zlib_decode(input, errors = 'strict'):
  13.     output = zlib.decompress(input)
  14.     return (output, len(input))
  15.  
  16.  
  17. class Codec(codecs.Codec):
  18.     
  19.     def encode(self, input, errors = 'strict'):
  20.         return zlib_encode(input, errors)
  21.  
  22.     
  23.     def decode(self, input, errors = 'strict'):
  24.         return zlib_decode(input, errors)
  25.  
  26.  
  27.  
  28. class IncrementalEncoder(codecs.IncrementalEncoder):
  29.     
  30.     def __init__(self, errors = 'strict'):
  31.         self.errors = errors
  32.         self.compressobj = zlib.compressobj()
  33.  
  34.     
  35.     def encode(self, input, final = False):
  36.         if final:
  37.             c = self.compressobj.compress(input)
  38.             return c + self.compressobj.flush()
  39.         else:
  40.             return self.compressobj.compress(input)
  41.  
  42.     
  43.     def reset(self):
  44.         self.compressobj = zlib.compressobj()
  45.  
  46.  
  47.  
  48. class IncrementalDecoder(codecs.IncrementalDecoder):
  49.     
  50.     def __init__(self, errors = 'strict'):
  51.         self.errors = errors
  52.         self.decompressobj = zlib.decompressobj()
  53.  
  54.     
  55.     def decode(self, input, final = False):
  56.         if final:
  57.             c = self.decompressobj.decompress(input)
  58.             return c + self.decompressobj.flush()
  59.         else:
  60.             return self.decompressobj.decompress(input)
  61.  
  62.     
  63.     def reset(self):
  64.         self.decompressobj = zlib.decompressobj()
  65.  
  66.  
  67.  
  68. class StreamWriter(Codec, codecs.StreamWriter):
  69.     pass
  70.  
  71.  
  72. class StreamReader(Codec, codecs.StreamReader):
  73.     pass
  74.  
  75.  
  76. def getregentry():
  77.     return codecs.CodecInfo(name = 'zlib', encode = zlib_encode, decode = zlib_decode, incrementalencoder = IncrementalEncoder, incrementaldecoder = IncrementalDecoder, streamreader = StreamReader, streamwriter = StreamWriter)
  78.  
  79.